home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / input.zip / INPUT.DOC < prev   
Text File  |  1987-05-12  |  4KB  |  104 lines

  1.  
  2.                               INPUT Ver. 1.0
  3.                             (c) Copyright 1986
  4.                              William C. Parke
  5.                                  for CHUG
  6.                         Capitol Heath Users' Group
  7.      
  8.             INPUT  is a  batch file  utility to get console input from
  9.      within a  batch file.  There are several variants of this type of
  10.      program in  the public domain.  A common type uses the ERRORLEVEL
  11.      to pass  a keyboard  response to  a BAT  file.   These  type  are
  12.      limited to  a single key transfer.  Another type, such as ANSWER,
  13.      written by  Frank Schweiger,  prompts for  a console  input, then
  14.      puts the  result into  an Environment Variable.  INPUT is of this
  15.      type, but  adds some refinement.  With INPUT, the response string
  16.      is set  to upper  case unless  the 'bare'  switch  is  used.    A
  17.      linefeed is  sent to  the console  after the  response to allow a
  18.      following ECHO  command.  In  addition,  preceding  and  trailing
  19.      blanks are  removed in the default mode.  Another option lets the
  20.      BAT file define the length of the string used in the response.
  21.      
  22.           The syntax for INPUT is the following:
  23.      
  24.              INPUT prompting string [/b/nn]
  25.      
  26.           Output of this program is placed in the Environment Variable
  27.      called ANS.   If  there is  no space left in the Environment, the
  28.      ERRORLEVEL is  set to  1.   If a  previous ANS  is found,  it  is
  29.      removed and  the new  ANS is placed at the end of the Environment
  30.      Variable list.  If there  is no  response to  the  INPUT  prompt,
  31.      ERRORLEVEL is  set to  1.   The prompting  string may contain any
  32.      standard ASCII  characters except  the dollar  sign and the slash
  33.      '/' character.   This  string is displayed on the console as soon
  34.      as INPUT  is evoked.  If no string is present, a help display for
  35.      the use  of INPUT  is displayed.   The brackets above enclose two
  36.      optional parameters.   Either  or both  may be  used.   They  are
  37.      defined as:
  38.      
  39.            b = bare input
  40.      
  41.            nn= a truncation number from 1 to 72
  42.      
  43.      If the  'b' switch  is used,  then the console response string is
  44.      left as  typed and  inserted into the Environment as the variable
  45.      ANS. Without  the 'b'  option, a  response string is converted to
  46.      upper case, and any preceding or trailing spaces are removed.  If
  47.      the 'nn'  truncation number  is used, the console response string
  48.      will be  truncated to  length nn before being used to define ANS.
  49.      This option  is useful  for insuring  that a  'yes-no' answer  is
  50.      properly  handled.    By  using  'nn'=1,  all  of  the  following
  51.      responses will give an ANS=Y : 'yes', 'y', ' yes', ' y', ' yes ',
  52.      ' y ',  'YES', 'Y', ' YES', ' Y', ' Y ', etc.
  53.      
  54.      
  55.      Example fragments from batch file applications:
  56.      
  57.      Example 1: Getting yes/no answers:
  58.      
  59.            IF EXIST %1 GOTO OK
  60.            INPUT %1 not found.  Do you wish to go on?  /1
  61.            IF %ANS%==Y GOTO OK
  62.            GOTO EXIT
  63.            :OK
  64.              ...
  65.            :EXIT
  66.            SET ANS=
  67.      
  68.        The last line of this example drops ANS from the Environment,
  69.      saving   space for additional variables.
  70.      
  71.      Example 2: Getting new path and file names:
  72.      
  73.            INPUT Give new file name:
  74.            SET FILE=%ANS%
  75.            SET ANS=
  76.            ...
  77.      
  78.      Note: A space should be added at the end of the colon above.
  79.      
  80.      Example 3: Starting a requested program:
  81.      
  82.            ECHO OFF
  83.            :START
  84.            TYPE PROGS.LST
  85.            REM PROGS.LST is an ascii list of programs
  86.            INPUT Enter program and command line, if needed :
  87.            IF ERRORLEVEL=1 GOTO EXIT
  88.            %ANS%
  89.            IF NOT ERRORLEVEL=1 GOTO EXIT
  90.            ECHO Program error.
  91.            ECHO  Please re-enter or type a carriage return.
  92.            GOTO START
  93.            :EXIT
  94.            SET ANS=
  95.      
  96.      Note that  the user can exit this BAT by typing a carriage return
  97.      in response  to the  INPUT string.   Alternatively, CTRL-C can be
  98.      used for the same purpose.
  99.      
  100.      Comments may be sent to the author via CHUG, Capital Heath Users'
  101.      Group, P.O. Box 16406, Arlington, VA 22215-1406.
  102.      
  103.  
  104.